import type Chinese from '@/locale/zh';

import { useI18n as _useI18n } from 'vue-i18n';

type I18Message = typeof Chinese;
type I18Key = keyof I18Message;

export const useI18n = <O extends I18Key, A extends I18Message[O], C extends keyof A>(block?: O|'') => {
	const { t } = _useI18n();

	return (txt: C) => t(`${block ? block + '.' : ''}${txt as string}`);
};
